//the coordinates of the shadow in light's eye space
varying vec4 shadowCoord;

//the vertex normal
varying vec3 normal;

//the direction to the light
varying vec3 lightDir;

//the view direction to the vertex
varying vec3 viewDir;

void main() {
  vec4 modelViewPosition = gl_ModelViewMatrix * gl_Vertex;

  gl_Position = gl_ProjectionMatrix * modelViewPosition;
  
  normal = normalize(gl_NormalMatrix * gl_Normal);
  
  //light source positions already in modelView space
  lightDir = normalize(gl_LightSource[0].position - modelViewPosition);
  
  viewDir = normalize(modelViewPosition);
  
  //project vertex into light's view space
  shadowCoord = gl_TextureMatrix[7] * gl_Vertex;
}
